<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib
        uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<%--    <base href="<%=basePath%>">--%>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="">
    <%-- <base href="<%=basePath%>"> --%>
    <title>备品配件验收指令单</title>
    <link rel="stylesheet"
          href="<%=basePath%>resourse/weui/lib/weui.min.css">
    <link rel="stylesheet"
          href="<%=basePath%>resourse/weui/css/jquery-weui.min.css">
    <script src="<%=basePath%>resourse/weui/lib/jquery-2.1.4.js"></script>
    <script src="<%=basePath%>resourse/weui/js/jquery-weui.min.js"></script>
</head>
<style>
    .form-value {
        margin-left: 30px;
    }

    .weui-label {
        display: block;
        width: 120px;
        word-wrap: break-word;
        word-break: break-all;
    }
    * {
        touch-action: pan-y;
    }
</style>
<body ontouchstart>
<script>
    $(function () {
        /**
         * 初始化下拉选项
         */
        $("#parUseCodeGroup").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parUseCodeGroupCode').val(values.data.values)
            }
        });
        const useCodeGroupOptions = getResultOptions('useCodeGroup')
        $("#parUseCodeGroup").select("update", {items: useCodeGroupOptions});

        $("#parUseCode").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parUseCodeTemp').val(values.data.values)
                $('#parUseText').val(values.data.titles)
            }
        });
        const useOptions = getResultOptions('use')
        $("#parUseCode").select("update", {items: useOptions});

        // 设置缺陷位置代码组下拉
        $("#deaBugAddressCodeGroup").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#deaBugAddressCodeGroupTemp').val(values.data.values)
                $('#deaBugAddressCodeGroupText').val(values.data.titles)
            }
        });
        const bugAddressCodeGroupOptions = getResultOptions('bugAddressCodeGroup')
        $("#deaBugAddressCodeGroup").select("update", {items: bugAddressCodeGroupOptions});

        $("#parBugAddressCodeGroup").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parBugAddressCodeGroupTemp').val(values.data.values)
                $('#parBugAddressCodeGroupText').val(values.data.titles)
            }
        });
        $("#parBugAddressCodeGroup").select("update", {items: bugAddressCodeGroupOptions});

        // 设置缺陷位置下拉
        $("#deaBugAddress").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#deaBugAddressCode').val(values.data.values)
                $('#deaBugAddressText').val(values.data.titles)
            }
        });
        const bugAddressOptions = getResultOptions('bugAddress')
        $("#deaBugAddress").select("update", {items: bugAddressOptions});

        $("#parBugAddressCode").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parBugAddressCodeTemp').val(values.data.values)
                $('#parBugAddressText').val(values.data.titles)
            }
        });
        $("#parBugAddressCode").select("update", {items: bugAddressOptions});

        // 设置缺陷类下拉
        $("#deaBugClass").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#deaBugClassCode').val(values.data.values)
                $('#deaBugClassText').val(values.data.titles)
            }
        });
        const bugClassOptions = getResultOptions('bugClass')
        $("#deaBugClass").select("update", {items: bugClassOptions});

        $("#parBugClass").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parBugClassCodeTemp').val(values.data.values)
                $('#parBugClassText').val(values.data.titles)
            }
        });
        $("#parBugClass").select("update", {items: bugClassOptions});

        // 设置缺陷类型下拉
        $("#deaBugType").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#deaBugTypeTemp').val(values.data.values)
                $('#deaBugTypeText').val(values.data.titles)
            }
        });
        const bugTypeOptions = getResultOptions('bugType')
        $("#deaBugType").select("update", {items: bugTypeOptions});

        $("#parBugType").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parBugTypeCodeTemp').val(values.data.values)
                $('#parBugTypeText').val(values.data.titles)
            }
        });
        $("#parBugType").select("update", {items: bugTypeOptions});

        // 设置缺陷类型代码组
        $("#deaBugTypeCodeGroup").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#deaBugTypeCodeGroupTemp').val(values.data.values)
                $('#deaBugTypeCodeGroupText').val(values.data.titles)
            }
        });
        const bugTypeCodeGroupOptions = getResultOptions('bugTypeCodeGroup')
        $("#deaBugTypeCodeGroup").select("update", {items: bugTypeCodeGroupOptions});

        $("#parBugTypeCodeGroup").select({
            title: "请选择",
            items: [],
            onClose: function (values) {
                $('#parBugTypeCodeGroupCodeTemp').val(values.data.values)
                $('#parBugTypeCodeGroupText').val(values.data.titles)
            }
        });
        $("#parBugTypeCodeGroup").select("update", {items: bugTypeCodeGroupOptions});


        /**
         * 页面加载时，初始化model的下拉值
         */
        let parBugAddressCodeGroup = '${partsModel.parBugAddressCodeGroup}'
        let parBugAddressGroupText = '${partsModel.parBugAddressGroupText}'
        // 缺陷位置代码组
        $('#parBugAddressCodeGroup').val(parBugAddressGroupText);
        $('#parBugAddressCodeGroup').attr("data-values", parBugAddressCodeGroup);
        // 缺陷位置
        let parBugAddressCode = '${partsModel.parBugAddressCode}'
        let parBugAddressText = '${partsModel.parBugAddressText}'
        $('#parBugAddressCode').val(parBugAddressText);
        $('#parBugAddressCode').attr("data-values", parBugAddressCode);
        // 缺陷类
        let parBugClassCode = '${partsModel.parBugClassCode}'
        let parBugClassText = '${partsModel.parBugClassText}'
        $('#parBugClass').val(parBugClassText);
        $('#parBugClass').attr("data-values", parBugClassCode);
        // 缺陷类型代码组
        let parBugTypeCodeGroup = '${partsModel.parBugTypeCodeGroup}'
        let parBugTypeCodeGroupText = '${partsModel.parBugTypeCodeGroupText}'
        $('#parBugTypeCodeGroup').val(parBugTypeCodeGroupText);
        $('#parBugTypeCodeGroup').attr("data-values", parBugTypeCodeGroup);
        // 缺陷类型代码
        let parBugTypeCode = '${partsModel.parBugTypeCode}'
        let parBugTypeText = '${partsModel.parBugTypeText}'
        $('#parBugType').val(parBugTypeText);
        $('#parBugType').attr("data-values", parBugTypeCode);
        let useCodegroup = '${partsModel.parUseCodeGroup}'
        // 设置决策代码组初始值
        $('#parUseCodeGroup').val(useCodegroup);
        $('#parUseCodeGroup').attr("data-values", useCodegroup);

        // 初始化决策代码的初始值
        let useCode = '${partsModel.parUseCode}'
        let parUseText = '${partsModel.parUseText}'
        $('#parUseCode').val(parUseText);
        $('#parUseCode').attr("data-values", useCode);

        /**
         * 初始化时间选择框的值
         * @type {string}
         */
        let parPracticalChenkStartDateTem = '${partsModel.parPracticalChenkStartDate}'
        $("#parPracticalChenkStartDate").datetimePicker({
            value: parPracticalChenkStartDateTem,
            onChange: function (result) {
                var dateValues = result.value
                var dateStr = dateValues[0] + '-' + dateValues[1] + '-' + dateValues[2] + ' ' + dateValues[3] + ':' + dateValues[4]
                $('#parPracticalCheckStartDateTemp').val(dateStr);
            }
        });
        let parPracticalChenkEndDateTem = '${partsModel.parPracticalChenkEndDate}'
        $("#parPracticalChenkEndDate").datetimePicker({
            value: parPracticalChenkEndDateTem,
            onChange: function (result) {
                var dateValues = result.value
                var dateStr = dateValues[0] + '-' + dateValues[1] + '-' + dateValues[2] + ' ' + dateValues[3] + ':' + dateValues[4]
                $('#parPracticalCheckEndDateTemp').val(dateStr);
                //   $('#parPracticalCheckEndDateTemp').val(dateValues.join('-'));
            }
        });
    })
</script>
<div class="weui-tab">
    <%--<div class="weui-navbar">
        <a class="weui-navbar__item weui-bar__item--on"> 备品配件验收指令明细</a>
    </div>--%>
    <div class="weui-tab__bd">
        <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
            <div class="weui-cells weui-cells_form" style="margin-top: 0px">
                <div class="weui-cells__title">检验批信息</div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">工厂：</label></div>
                    <div class="weui-cell__bd">
                        <%-- parId --%>
                        <input type="hidden" value="${partsModel.parId}" id="parId">
                        <%-- 接口id --%>
                        <input type="hidden" value="${partsModel.interfaceId}" id="interfaceId">
                        <%--                工厂CODE--%>
                        <input type="hidden" value="${partsModel.parFactory}" id="parFactory">
                        <%--                            检验批status--%>
                        <input type="hidden" value="${partsModel.status}" id="partStatus">
                        <input class="weui-input form-value" type="text" value="${partsModel.parFactoryDetail}">
                    </div>

                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验批号编号：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckCode}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验批来源：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckSourse}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验类型：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckType}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">物料编号：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.mmCode}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">物料描述：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.mmDetail}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">批次编号：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCode}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">存储地点：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parAddress}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">组：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parGroup}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">组计数器：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parGroupNum}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验开始日期：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckStartDate}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验结束日期：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckEndDate}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">用途：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parUse}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验批数量：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parCheckNum}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">供应商：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parSupplyCode}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">供应商名称：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parSupplyName}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">采购凭证：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parProof}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">采购凭证的项目编号：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.parProjectNum}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">物料凭证：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.mmProof}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">物料凭证中的项目：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.mmProofProject}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">创建人姓名：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.createName}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">创建时间：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" value="${partsModel.createTime}">
                    </div>
                </div>
                <div class="weui-cell" style="display: none">
                    <div class="weui-cell__hd"><label class="weui-label">使用决策代码组：</label></div>
                    <div class="weui-cell__bd">
                        <input type="hidden" id="parUseCodeGroupCode" value="${partsModel.parUseCodeGroup}">
                        <input class="weui-input form-value" type="text" id='parUseCodeGroup' placeholder="请选择">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">检验员：</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input form-value" type="text" id='parInspector'>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">使用决策代码：</label></div>
                    <div class="weui-cell__bd">
                        <input type="hidden" id="parUseCodeTemp" value="${partsModel.parUseCode}">
                        <input type="hidden" id="parUseText" value="${partsModel.parUseText}">
                        <input class="weui-input form-value" type="text" id='parUseCode' placeholder="请选择">
                    </div>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">实际检验开始时间：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parPracticalCheckStartDateTemp"
                           value="${partsModel.parPracticalChenkStartDate}">
                    <input class="weui-input form-value" type="text" id='parPracticalChenkStartDate'
                           placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">实际检验结束时间：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parPracticalCheckEndDateTemp"
                           value="${partsModel.parPracticalChenkEndDate}">
                    <input class="weui-input form-value" type="text" id='parPracticalChenkEndDate'
                           placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">缺陷位置代码组：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parBugAddressCodeGroupTemp"
                           value="${partsModel.parBugAddressCodeGroup}">
                    <input type="hidden" id="parBugAddressCodeGroupText"
                           value="${partsModel.parBugAddressGroupText}">
                    <input class="weui-input form-value" type="text" id='parBugAddressCodeGroup' placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">缺陷位置：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parBugAddressCodeTemp" value="${partsModel.parBugAddressCode}">
                    <input type="hidden" id="parBugAddressText" value="${partsModel.parBugAddressText}">
                    <input class="weui-input form-value" type="text" id='parBugAddressCode' placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">缺陷类：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parBugClassCodeTemp" value="${partsModel.parBugClassCode}">
                    <input type="hidden" id="parBugClassText" value="${partsModel.parBugClassText}">
                    <input class="weui-input form-value" type="text" id='parBugClass' placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">缺陷类型代码组：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parBugTypeCodeGroupCodeTemp" value="${partsModel.parBugTypeCodeGroup}">
                    <input type="hidden" id="parBugTypeCodeGroupText" value="${partsModel.parBugTypeCodeGroupText}">
                    <input class="weui-input form-value" type="text" id='parBugTypeCodeGroup' placeholder="请选择">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">缺陷类型：</label></div>
                <div class="weui-cell__bd">
                    <input type="hidden" id="parBugTypeCodeTemp" v alue="${partsModel.parBugTypeCode}">
                    <input type="hidden" id="parBugTypeText" value="${partsModel.parBugTypeText}">
                    <input class="weui-input form-value" type="text" id='parBugType' placeholder="请选择">
                </div>
            </div>
            <div class="weui-cells" style="margin-top: 0px">
                <div class="weui-cells__title">工序列表</div>
                <c:forEach items="${processModels}" var="item">
                    <a class="weui-cell weui-cell_access"
                       onclick="goPartItem('${item.procId}')"
                       href="javascript:void(0);">
                        <input type="hidden" id="procId" value="${item.procId}">
                        <div class="weui-cell__bd">
                            <p>${item.procNum} ${item.procText}</p>
                        </div>
                    </a>
                </c:forEach>
            </div>
        </div>
    </div>
    <c:if test="${partsModel.status !='1'}">
        <a href="javascript:;" style="width: 96%;margin: 20px auto" onclick="operation()" id="operation"
           class="weui-btn weui-btn_primary">操作</a>
    </c:if>
</div>

<!-- 如果使用了某些拓展插件还需要额外的JS -->
<script src="<%=basePath%>resourse/weui/js/swiper.min.js"></script>
<script src="<%=basePath%>resourse/weui/js/city-picker.min.js"></script>
<script src="<%=basePath%>resourse/weui/lib/fastclick.js"></script>
<script>

    var loading = false;  //状态标记
    $(function () {
        FastClick.attach(document.body);
        $(document.body).infinite(50);
    })

    /**
     * 提交至sap
     */
    function operation() {
        let useCode = $('#parUseCodeTemp').val()
        let parUseText = $('#parUseText').val()
        let parId = $('#parId').val()
        let part = {
            parId: parId,
            parUseCodeGroup: '1000',
            parUseCode: useCode,
            parUseText: parUseText,
            parInspector: $('#parInspector').val(),
            parPracticalChenkStartDate: $('#parPracticalCheckStartDateTemp').val(),
            parPracticalChenkEndDate: $('#parPracticalCheckEndDateTemp').val(),
           // parUseCodeGroup: $('#parUseCodeGroupCode').val(),
            parBugTypeCodeGroup: $('#parBugTypeCodeGroupCodeTemp').val(),
            parBugTypeCodeGroupText: $('#parBugTypeCodeGroupText').val(),
            parBugTypeCode: $('#parBugTypeCodeTemp').val(),
            parBugTypeText: $('#parBugTypeText').val(),
            parBugAddressCode: $('#parBugAddressCodeTemp').val(),
            parBugAddressText: $('#parBugAddressText').val(),
            parBugAddressCodeGroup: $('#parBugAddressCodeGroupTemp').val(),
            parBugAddressGroupText: $('#parBugAddressCodeGroupText').val(),
            parBugClassCode: $('#parBugClassCodeTemp').val(),
            parBugClassText: $('#parBugClassText').val(),
            status: '0'
        }
        $.actions({
            actions: [{
                text: "保存",
                onClick: function () {
                    save(part, '')
                }
            }, {
                text: "提交",
                onClick: function () {
                    if (!useCode) {
                        $.toptip('请输入决策', 'error');
                        return
                    }
                    $.confirm("点击提交后无法对此检验批进行修改，请确认", function () {
                        //点击确认后的回调函数
                        $.showLoading();
                        // let useCodeGroup = $('#parUseCodeGroupCode').val()
                        part.status = '1'
                        $.ajax({
                            type: 'post',
                            headers: {
                                token: localStorage.getItem("token")
                            },
                            dataType: 'json',
                            url: '<%=basePath%>api/qm/parts/commit',
                            data: JSON.stringify(part),
                            contentType: "application/json",
                            success: function (data) {
                            },
                            complete: function (XMLHttpRequest) {
                                $.hideLoading();
                                if (XMLHttpRequest.responseJSON.code != 60200) {
                                    $.toast(XMLHttpRequest.responseJSON.msg, 1000, function () {
                                    });
                                } else {
                                    $.toast(XMLHttpRequest.responseJSON.msg, 1000, function () {
                                        window.location.href = "<%=basePath%>wx/qm/index?status=0"
                                    });
                                }
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(errorThrown);
                            }
                        })

                    }, function () {
                        //点击取消后的回调函数
                    });
                }
            }]
        });
    }

    // 点击进入检验特性列表
    function goPartItem(procId) {
        let useCode = $('#parUseCodeTemp').val()
        let parUseText = $('#parUseText').val()
        let parId = $('#parId').val()
        let partStatus = $('#partStatus').val()
        let part = {
            parId: parId,
            procId: procId,
            parUseCodeGroup: '1000',
            parUseCode: useCode,
            parUseText: parUseText,
            parInspector: $('#parInspector').val(),
            parPracticalChenkStartDate: $('#parPracticalCheckStartDateTemp').val(),
            parPracticalChenkEndDate: $('#parPracticalCheckEndDateTemp').val(),
           // parUseCodeGroup: $('#parUseCodeGroupCode').val(),
            parBugTypeCodeGroup: $('#parBugTypeCodeGroupCodeTemp').val(),
            parBugTypeCodeGroupText: $('#parBugTypeCodeGroupText').val(),
            parBugTypeCode: $('#parBugTypeCodeTemp').val(),
            parBugTypeText: $('#parBugTypeText').val(),
            parBugAddressCode: $('#parBugAddressCodeTemp').val(),
            parBugAddressText: $('#parBugAddressText').val(),
            parBugAddressCodeGroup: $('#parBugAddressCodeGroupTemp').val(),
            parBugAddressGroupText: $('#parBugAddressCodeGroupText').val(),
            parBugClassCode: $('#parBugClassCodeTemp').val(),
            parBugClassText: $('#parBugClassText').val(),
            status: '0'
        }
        // 1.首先保存检验批
        // 当检验批为未提交时，保存检验批
        if (partStatus == '0') {
            save(part, 'skip')
        } else {
            window.location.href = "<%=basePath%>qm/partItems?procId=" + procId + "&parId=" + part.parId
        }

    }

    // 保存检验批
    function save(part, action) {
        let procId = part.procId
        $.showLoading();
        $.ajax({
            headers: {
                token: localStorage.getItem("token")
            },
            type: 'post',
            dataType: 'json',
            url: '<%=basePath%>api/qm/parts/save',
            data: JSON.stringify(part),
            contentType: "application/json",
            complete: function (XMLHttpRequest) {
                $.hideLoading();
                if (XMLHttpRequest.responseJSON.code != 60200) {
                    $.toptip('保存失败', 2000, 'warning');
                } else {
                    //2.保存成功后，
                    $.toptip('保存成功', 2000, 'success');
                    if (action == 'skip') {
                        window.location.href = "<%=basePath%>qm/partItems?procId=" + procId + "&parId=" + part.parId
                    }
                }
            }
        })
    }

    function getResultOptions(type) {
        let optionsTem = []
        $.ajax({
            type: "get",
            url: "<%=basePath%>api/qm/parts/getPartsOptions?type=" + type,
            dataType: "json",
            async: false,
            headers: {
                token: localStorage.getItem("token")
            },
            success: function (data) {
                if (data.code == 60200) {
                    optionsTem = data.data
                } else {
                    $.toptip('获取配置项失败', 'error');
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });
        // 在第一行加入一个空值对象，用来取消选中
        optionsTem.unshift({
            "data-values": "",
            "title": "--",
            "type": type,
            "value": ""
        })
        return optionsTem
    }
</script>

</body>

</html>